﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		User.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            User.cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion
 
using System;
using System.Collections.Generic;

namespace Dexter.Domain.Model {
	public partial class User : EntityBase {
		readonly string username;
		string email;

		protected User ( ) {
			Roles = new List <Role> ( );
		}

		internal User ( string username , HashProvider hashProvider , string password , EncryptDataFormat encryptDataFormat ) {
			this.username = username;
			LoweredUsername = username.ToLowerInvariant ( );
			HashProvider = hashProvider;
			EncryptDataFormat = encryptDataFormat;
			ChangePassword ( password );
			
			FailedPasswordAnswerAttemptWindowStart = DateTime.Now;
			FailedPasswordAttemptWindowStart = DateTime.Now;
			LastActivityDate = DateTime.Now;
			LastLockedOutDate = DateTime.Now;
			LastLoginDate = DateTime.Now;
			LastPasswordChangeDate = DateTime.Now;

			Roles = new List<Role>();
		}

		public virtual string Description { get; set; }
		public virtual string LoweredUsername { get; protected set; }
		public virtual string Comments { get; set; }

		public virtual string Username {
			get { return username; }
		}

		public virtual string Email {
			get { return email; }
			set {
				email = value;
				LoweredEmail = value.ToLower ( );
			}
		}

		public virtual IList <Role> Roles { get; set; }
		public virtual int FailedPasswordAnswerAttemptCount { get; set; }
		public virtual DateTime FailedPasswordAnswerAttemptWindowStart { get; set; }
		public virtual int FailedPasswordAttemptCount { get; set; }
		public virtual DateTime FailedPasswordAttemptWindowStart { get; set; }
		public virtual HashProvider HashProvider { get; set; }
		public virtual bool IsApproved { get; protected set; }
		public virtual bool IsLockedOut { get; protected set; }
		public virtual DateTime LastActivityDate { get; set; }
		public virtual DateTime LastLockedOutDate { get; set; }
		public virtual DateTime LastLoginDate { get; set; }
		public virtual DateTime LastPasswordChangeDate { get; set; }
		public virtual string LoweredEmail { get; protected set; }
		public virtual string Password { get; protected set; }
		public virtual string PasswordAnswer { get; set; }
		public virtual EncryptDataFormat EncryptDataFormat { get; protected set; }
		public virtual string PasswordQuestion { get; protected set; }
		public virtual string PasswordSalt { get; protected set; }
		public virtual string PasswordAnswerSalt { get; protected set; }
	}
}
